<%@page import="com.iflysse.bbs.model.UserInfo"%>
<%@page import="com.iflysse.bbs.model.NewsInfo"%>
<%@page import="java.util.List"%>
<%@page import="com.iflysse.bbs.dao.impl.NewsDaoImpl"%>
<%@page import="com.iflysse.bbs.dao.NewsDao"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="../base.jsp"%>
<%
	//检查是否登陆
	if (session.getAttribute("currentUser") == null) {
		request.getRequestDispatcher("/index_handler.jsp").forward(
				request, response);
		return;
	}

	UserInfo currentUser = (UserInfo) session
			.getAttribute("currentUser");

	//获取查询的值（点击查询按钮进来处理）
	String title = null;
	if (request.getParameter("qtitle") != null) {
		title = request.getParameter("qtitle").toString();
	}

	NewsDao newsDao = new NewsDaoImpl();
	List<NewsInfo> newsList = null;
	if (title == null) {
		//默认首页进来
		newsList = newsDao.getNewsList(currentUser.getId());
	} else {
		//点击查询按钮进来
		newsList = newsDao.getNewsList(title, currentUser.getId());
	}

	request.setAttribute("newsData", newsList);
	request.getRequestDispatcher("/pages/personal/newslist.jsp")
			.forward(request, response);
%>